﻿namespace Practices.IdentityProvider {
    using System;
    using System.Collections.Generic;
    using System.IdentityModel;
    using System.IdentityModel.Services;
    using System.Linq;
    using System.Security.Claims;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class PassivePage : System.Web.UI.Page {
        ContosoSecurityTokenServiceConfiguration stsConfiguration;
        SecurityTokenService securityTokenService;

        /// <summary>
        /// Perform the WS-Federation Passive Protocol processing in this method. 
        /// </summary>
        protected void Page_PreRender(object sender, EventArgs e) {
            stsConfiguration = new ContosoSecurityTokenServiceConfiguration();
            securityTokenService = new ContosoSecurityTokenService(this.stsConfiguration);

            ClaimsPrincipal principal = User as ClaimsPrincipal;

            FederatedPassiveSecurityTokenServiceOperations.ProcessRequest(
                Request,
                principal,
                securityTokenService,
                Response);
        }
    }
}